package com.itheima.info.manage.sysytem.service;

import com.itheima.info.manage.sysytem.dao.TeacherDao;
import com.itheima.info.manage.sysytem.domain.Teacher;

public class TeacherService {
    TeacherDao teacherDao=new TeacherDao();
    public static boolean addTeacher(Teacher teacher) {
        boolean flag=TeacherDao.addTeacher(teacher);

        return false;
    }
    public static boolean exists(String sid) {
        Teacher[]teacher=TeacherDao.findallTeacher();
        boolean flag=false;
        for (int i = 0; i <teacher.length ; i++) {
            Teacher tea=teacher[i];
            if (tea!=null&&tea.getSid().equals(sid)){
                return true;
            }
        }
        return false;
    }

    public static Teacher[] findallTeacher() {
        Teacher[]teachers=TeacherDao.findallTeacher();
         boolean flag=false;
        for (int i = 0; i <teachers.length ; i++) {
            Teacher tea=teachers[i];
            if (tea!=null){
                flag=true;
            }
        }
        if (flag){
            return teachers;
        }else {
            return null;
        }

    }

    public static void deletaTeacher(String sid) {
    TeacherDao.deletaTeacher(sid);
    }

    public static void updateTeacher(String sid, Teacher teacher) {
        TeacherDao.updateTeacher(sid,teacher);
    }
}
